<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Inv_roles extends CI_Controller {

	public function __construct(){
		parent::__construct();
		$this->load->model('wus');
		$this->load->model($this->session->userdata('formodel'));
		$this->load->library('variable');
	}

	public function index(){

	  $this->load->view('layouts/header',$this->variable->load_data($this->session->userdata('title')));
	  $this->load->view($this->session->userdata('formain'),array(
	  		'officer'	=> $this->inv_roles_model->get_inv_roles()
	  	));
	  $this->load->view('layouts/footer');
	}
	public function add_form(){
				$this->load->view($this->session->userdata('foradd'),array(
					'officer'	=> $this->inv_roles_model->get_inv_roles(),
					'users'		=> $this->inv_roles_model->get_inv_users($this->session->userdata('company_id'))
					));
	}
	public function edit_form($id){

			$this->load->view($this->session->userdata('foredit'),array(
					'offcr_data'	=> $this->inv_roles_model->get_offcr_data($id),
					'officer'	=> $this->inv_roles_model->get_inv_roles()
				));
		
	}
	public function view_form($id){
			$this->load->view($this->session->userdata('forview'),array(
					'offcr_data'	=> $this->inv_roles_model->get_offcr_data($id),
					'officer'	=> $this->inv_roles_model->get_inv_roles()
				));
	}

	public function get_usrinfo(){
		$this->inv_roles_model->get_userinfo($this->input->post('user_id'));
	}

	public function insert_inv_offcr(){
		$data = array(
			':p_user_id'		=> $this->input->post('role_un_inv'),
			':p_role_code'		=> $this->input->post('role_offcr_inv'),
			':p_enable_flag'	=> ($this->input->post('offcr_stat') == 'ok' ? 'Y' : 'N'),
			':pl_user_id'		=> $this->session->userdata('user_id')
			);
		$this->inv_roles_model->insert_offcr($data);
	}

	public function update_offcr(){
		$data = array(
			':p_inv_role_id'	=> $this->input->post('e_invrole_id'),
			':p_role_code'		=> $this->input->post('edit_offcr_role'),
			':p_enable_flag'	=> ($this->input->post('edit_offcr_ena') == 'ok' ? 'Y' : 'N'),
			':p_user_id'		=> $this->session->userdata('user_id')
			);
		$this->inv_roles_model->update_offcr($data);
	}


	public function searchOffcr(){
 		$un = $this->input->post('username');
		$rc = $this->input->post('rolecode');
		$query = $this->inv_roles_model->search_offcr($un, $rc);

		if(!empty($query)) {
			echo json_encode($query);
		}else{
			echo json_encode("none");
		}
 	}

	
	
	 
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */